<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>坦克大战 - 游戏</title>
    <link rel="stylesheet" href="/css/joystick.css">
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f0f0f0;
            overflow: hidden;
        }
        .game-container {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }
        canvas {
            display: block;
            width: 100%;
            height: 100%;
            background-color: #EEEEEE;
            border: none;
            box-shadow: none;
        }
        .game-info, .controls {
            display: none; /* 隐藏原来的UI元素 */
        }
        .waiting-message {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: rgba(0, 0, 0, 0.7);
            color: white;
            padding: 20px;
            border-radius: 10px;
            text-align: center;
            display: none;
            z-index: 10;
        }
        .victory-dialog {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: rgba(0, 0, 0, 0.8);
            color: white;
            padding: 30px;
            border-radius: 15px;
            text-align: center;
            display: none;
            z-index: 20;
            box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
        }
        .victory-dialog h2, .defeated-dialog h2 {
            color: gold;
            margin: 0 0 20px 0;
            font-size: 24px;
        }
        .victory-dialog button, .defeated-dialog button {
            background-color: gold;
            color: black;
            border: none;
            padding: 10px 20px;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
            margin-top: 25px;
            transition: background-color 0.3s;
            display: block;
            margin-left: auto;
            margin-right: auto;
        }
        .victory-dialog button:hover, .defeated-dialog button:hover {
            background-color: #ffd700;
        }
        .defeated-dialog {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: rgba(0, 0, 0, 0.8);
            color: white;
            padding: 30px;
            border-radius: 15px;
            text-align: center;
            display: none;
            z-index: 20;
            box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
        }
    </style>
</head>
<body>
    <div class="game-info">
        <div class="player-info">玩家: <span id="playerName"></span></div>
        <div class="room-info">房间: <span id="roomId"></span></div>
    </div>
    
    <div class="game-container">
        <canvas id="gameCanvas"></canvas>
        <div id="waitingMessage" class="waiting-message">
            <h2>等待其他玩家加入...</h2>
            <p>游戏将在有足够玩家时自动开始</p>
        </div>
        <div id="victoryDialog" class="victory-dialog">
            <h2>恭喜你吃鸡了！</h2>
            <button id="returnToRoomList">返回房间列表</button>
        </div>
        <div id="defeatedDialog" class="defeated-dialog">
            <h2>你的坦克被击毁了！</h2>
            <button id="returnToRoomListDefeated">返回房间列表</button>
        </div>
    </div>
    
    <div class="controls">
        <button id="backButton">返回房间列表</button>
    </div>
    
    <!-- 触摸控制界面 -->
    <div class="touch-controls">
        <div class="direction-pad">
            <button class="direction-button up-button">↑</button>
            <button class="direction-button down-button">↓</button>
            <button class="direction-button left-button">←</button>
            <button class="direction-button right-button">→</button>
        </div>
        <button class="shoot-button">🔥</button>
    </div>

    <!-- 引入Socket.io客户端库 -->
    <script src="/socket.io/socket.io.js"></script>
    
    <!-- 引入玩家ID管理 -->
    <script src="/js/player-id.js"></script>
    
    <!-- 引入游戏实体类 -->
    <script src="/js/entities/tank.js"></script>
    <script src="/js/entities/bullet.js"></script>
    <script src="/js/entities/wall.js"></script>
    
    <!-- 引入ECS架构 -->
    <script src="/js/ecs/world.js"></script>
    
    <!-- 引入游戏系统 -->
    <script src="/js/joystick.js"></script>
    <script src="/js/systems/render-system.js"></script>
    <script src="/js/systems/input-system.js"></script>
    <script src="/js/systems/collision-system.js"></script>
    <script src="/js/systems/network-system.js"></script>
    
    <!-- 引入主游戏逻辑 -->
    <script src="/js/main.js"></script>
</body>
</html>